﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiposComuns.Objectos;

namespace Servidor.Objectos
{
    /// <summary>
    /// Removes a friend
    /// </summary>
    [Serializable]
    public class RemoveFriendAction : Action
    {
        #region Attributes
        private Person source;          //Friend to be removed
        #endregion

        #region Constructors
        public Person Source
        {
            get { return source.Clone(); }
            set { source = value.Clone(); }
        }

        public RemoveFriendAction() { }

        public RemoveFriendAction(IDMsg id, Person source) : base(id)
        {
            this.source = source.Clone();
        }
        #endregion

        #region Methods
        public override void Execute(User user)
        {
            user.RemoveFriend(source);
        }

        public override void RollBack(User user)
        {
            NewFriendPost np = new NewFriendPost();
            np.Requester = this.source;            
            user.AcceptFriend(np);
        }
        #endregion
    }
}

